//
//  AppDelegate.swift
//  CJPackDemo
//
//  Created by 陈警卫 on 2023-12-05.
//

import UIKit
import CJPack

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    
    // 创建window
    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        // 程序启动
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.makeKeyAndVisible()
        
        handleFrontCompose()
        showRootController()
        
        return true
    }
}

/// MARK: 业务处理
extension AppDelegate {
    
    func handleFrontCompose() {
        
        
    }
    
    // 进入主程序
    func showRootController() {
        window?.rootViewController?.removeFromParent()
        window?.cj_removeAllSubviews()
        window?.rootViewController = CPRootController.rootTC()
    }
}

/// MARK: 生命周期
extension AppDelegate {
    
    func applicationWillResignActive(_ application: UIApplication) {
        // 程序即将进入后台
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // 程序进入后台
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // 程序即将进入前台
    }
    
    func applicationDidBecomeActive(_ application: UIApplication) {
        // 程序重新激活
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // 程序终结
    }
}

